<?php
namespace plugin\banmitongcheng\admin;
 

use plugin\banmitongcheng\common\Common;

use app\admin\common\Baseadmin;
use think\facade\Db; 

class Paypaymethod extends Baseadmin
{
    
    
          protected   $plugin  ='banmitongcheng';     //插件别名
          protected   $field   ='payment_config';  // zenkuai_home_plugin_list_config 表的字段
          protected   $files   ='set_pay';     //插件里的php配置文件
 
        
       /**
        * 查询 
        * @param list 查询配置文件
        * @param     
        */
      public function lists() {

             $data = (new Common())->get_php_other($this->field , $this->files );
             
             ajaxmsg('ok', 200,$data);  
             
      }
        
 
            public function   switch_open(){  
                
                
        
          
               
                  $id = input('request.id'); 
                  
                  $ret = (new Common())->get_php_other($this->field , $this->files  );
                  
               
                  
                  $list =   $ret['list']; 
                
                  if (isset($ret['list'][0])) {
                      
                       
                         foreach ($list as $key => $value) {
                                if ($id==$value['id']) {
                                    $find= $value;
                                    $find['open'] = $find['open'] == 1 ? 0 : 1;
                                    $list[$key] = $find;
                                    break;
                                }   
                          }
                      $list =json_encode($list);
                      Db::name('home_plugin_list_config')->where('catalogue', $this->plugin)->update(['payment_config' => $list ]);
                        
                        ajaxmsg('保存成功', 200,$find['open']);  
                        
                   }  
                  
            }  
                  
          
    
    
    
}